import { Injectable } from "@angular/core";
import { PickerColumn, PickerController, PopoverController, AlertController } from "ionic-angular";
// import { ReloadingController } from '../components/reloading/reloading-controller';
import {Device} from "@ionic-native/device";

declare var window: {
  localStorage: {
    setItem: any,
    getItem: any
  }
};

@Injectable()
export class ComponentUtilService {

  constructor(
    public popover: PopoverController,
    public alertCtrl: AlertController,
    public pickerCtrl: PickerController,
    public device: Device
    // public loadingCtrl: ReloadingController
  ) {


  }

  avoidChromeRefreshError(_this, obj) {
    // TODO
    if (!this.device.cordova) {
      for (let key in obj) {
        if (_this[key]) {
          window.localStorage.setItem('debug-' + key, _this[key]);
        } else {
          _this[key] = window.localStorage.getItem('debug-' + key);
        }
      }
     }
  }

}
